package stack

import (
	"jvm/nzpJvm/instructions/base"
	"jvm/nzpJvm/runtime_area"
)

// 将栈顶两个元素互换（元素不能是double和long类型）
type SWAP struct {
	base.NoOperandsInstruction
}

// 弹出两个元素，并且调换顺序入栈
func (self *SWAP)Execute(frame *runtime_area.Frame)  {
	high := frame.OperandStack().PopSlot()
	low := frame.OperandStack().PopSlot()

	frame.OperandStack().PushSlot(high)
	frame.OperandStack().PushSlot(low)
}


